package com.ht.baselibs.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.ht.baselibs.ui.base.BaseViewHolder;

import java.util.List;

public abstract class DefaultNoTagAdapter<T> extends BaseAdapter {
    private List<T> mData;

    protected Context mContext;

    public DefaultNoTagAdapter(Context context, List<T> data) {
        mContext = context;
        mData = data;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public T getItem(int position) {
        return mData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        BaseViewHolder<T> viewHolder;
        viewHolder = getViewHolder(position, mData);
        viewHolder.setData(mData.get(position));
        return viewHolder.getRootView();
    }
    protected abstract BaseViewHolder<T> getViewHolder(int position, List<T> mData);
}
